package com.ssm.netty.splitpacket;

import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.SimpleChannelInboundHandler;
import io.netty.util.CharsetUtil;

public class MyServerHandler extends SimpleChannelInboundHandler<MyMessageProtocol> {

    int num = 0;

    @Override
    protected void channelRead0(ChannelHandlerContext channelHandlerContext, MyMessageProtocol myMessageProtocol) throws Exception {
        System.out.println("===服务端接收到的消息如下===");

        System.out.println("长度=" + myMessageProtocol.getLen());
        System.out.println("内容=" + new String(myMessageProtocol.getContent(), CharsetUtil.UTF_8));
        System.out.println("服务端接收到的消息包数量=" + (++num) + "\n");

    }
}
